/**  
* @project_name mfq_comm
* @Title: Hessian.java
* @Package com.yjd.comm.annotation
* @Description: TODO
* @author renbangjie renbangjie@126.com  
* @date 2014-8-31 下午3:33:31
* @version V1.0  
* <b>Copyright (c)</b> 2014医信金融信息服务（上海）有限公司-版权所有<br/>
*/
package com.yjd.comm.annotation;

import com.caucho.hessian.client.HessianProxyFactory;

import java.net.MalformedURLException;

/**
 * @ClassName: Hessian
 * @Description: TODO
 * @author renbangjie renbangjie@126.com
 * @date 2014-8-31 下午3:33:31
 */
public class Hessian {
	
	private static Hessian instance;
	
	private HessianProxyFactory hessianProxyFactory;
	
	private Hessian(){
		this.hessianProxyFactory = new HessianProxyFactory();
	}
	
	private static synchronized void getHessian(){
		if(instance!=null){
			return;
		}
		instance = new Hessian();
	}
	
	public static Hessian getInstance() {
		getHessian();
		return instance;
	}
	
	@SuppressWarnings("rawtypes")
	public Object getService(Class cls, String url) throws MalformedURLException{
		hessianProxyFactory.setOverloadEnabled(true);
		return hessianProxyFactory.create(cls, url);
	}
}
